<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>
<style>
    .layui-form-label {
        width: 150px;
    }

    .layui-input-block {
        margin-left: 180px;
        min-height: 36px
    }
</style>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>全局配置</legend>
</fieldset>

<form class="layui-form" lay-filter="settingData">
    <div class="layui-form-item">
        <label class="layui-form-label">开发人员</label>
        <div class="layui-input-block">
            <input type="text" name="globalConfig.author" lay-verify="title" autocomplete="off" placeholder="请输入开发人员名称"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">swagger2文档</label>
            <div class="layui-input-block">
                <input type="checkbox" name="globalConfig.swagger2" lay-skin="switch" lay-filter="switchSwagger2"
                       value="true" lay-text="ON|OFF">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">ActiveRecord模式</label>
            <div class="layui-input-block">
                <input type="checkbox" name="globalConfig.activeRecord" lay-skin="switch" lay-filter="switchTest"
                       value="true" lay-text="ON|OFF">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">生成BaseResultMap</label>
            <div class="layui-input-block">
                <input type="checkbox" name="globalConfig.baseResultMap" lay-skin="switch"
                       lay-filter="switchBaseResultMap" value="true" lay-text="ON|OFF">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">生成serialVersionUID</label>
            <div class="layui-input-block">
                <input type="checkbox" checked="" name="strategy.entitySerialVersionUID" lay-skin="switch"
                       lay-filter="switchSerialVersionUID" value="true" lay-text="ON|OFF">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">实体为lombok模型</label>
            <div class="layui-input-block">
                <input type="checkbox" name="strategy.entityLombokModel" lay-skin="switch" lay-filter="switchLombok"
                       value="true" lay-text="ON|OFF">
            </div>
        </div>

    </div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>各层文件名称方式，例如： %sAction 生成 UserAction %s 为占位符</legend>
    </fieldset>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">entity层</label>
            <div class="layui-input-block">
                <input type="text" name="globalConfig.entityName" lay-verify="naming" autocomplete="off"
                       placeholder="默认：User" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">dao层</label>
            <div class="layui-input-block">
                <input type="text" name="globalConfig.mapperName" lay-verify="naming" autocomplete="off"
                       placeholder="默认：UserMapper" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">mapper层</label>
            <div class="layui-input-block">
                <input type="text" name="globalConfig.xmlName" lay-verify="naming" autocomplete="off"
                       placeholder="默认：UserMapper.xml" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">service层</label>
            <div class="layui-input-block">
                <input type="text" name="globalConfig.serviceName" lay-verify="naming" autocomplete="off"
                       placeholder="默认：IUserService" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">serviceImpl层</label>
            <div class="layui-input-block">
                <input type="text" name="globalConfig.serviceImplName" lay-verify="naming" autocomplete="off"
                       placeholder="默认：UserServiceImpl" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">controller层</label>
            <div class="layui-input-block">
                <input type="text" name="globalConfig.controllerName" lay-verify="naming" autocomplete="off"
                       placeholder="默认：UserController" class="layui-input">
            </div>
        </div>
    </div>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>包相关配置</legend>
    </fieldset>

    <div class="layui-form-item">
        <label class="layui-form-label">父包名</label>
        <div class="layui-input-block">
            <input type="text" name="packageInfo.parent" lay-verify="title" autocomplete="off"
                   placeholder="默认：null " class="layui-input">
            <div class="layui-form-mid layui-word-aux">eg:com.lfy.generator</div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">Entity包名</label>
            <div class="layui-input-block">
                <input type="text" name="packageInfo.entity" lay-verify="title" autocomplete="off"
                       placeholder="默认：entity" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Mapper包名</label>
            <div class="layui-input-block">
                <input type="text" name="packageInfo.mapper" lay-verify="title" autocomplete="off"
                       placeholder="默认：mapper" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Mapper XML包名</label>
            <div class="layui-input-block">
                <input type="text" name="packageInfo.xml" lay-verify="title" autocomplete="off"
                       placeholder="默认：mapper.xml" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Service包名</label>
            <div class="layui-input-block">
                <input type="text" name="packageInfo.service" lay-verify="title" autocomplete="off"
                       placeholder="默认：service" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Service Impl包名</label>
            <div class="layui-input-block">
                <input type="text" name="packageInfo.serviceImpl" lay-verify="title" autocomplete="off"
                       placeholder="默认：service.impl" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">Controller包名</label>
            <div class="layui-input-block">
                <input type="text" name="packageInfo.controller" lay-verify="title" autocomplete="off"
                       placeholder="默认：controller" class="layui-input">
            </div>
        </div>

    </div>


    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="save-setting">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


<script src="../../layuiadmin/layui/layui.js" charset="utf-8"></script>

<script>
    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['form', 'layedit', 'laydate', 'index'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , setter = layui.setter
            , laydate = layui.laydate;


        //自定义验证规则
        form.verify({
            naming: function (value) {
                if (value !== '' && value.indexOf("%s") === -1) {
                    return '命名中应包含占位符%s';
                }
            }
        });

        //监听指定开关
        form.on('switch(switchLombok)', function (data) {
            layer.tips('【实体】是否为lombok模型', data.othis)
        });
        form.on('switch(switchSerialVersionUID)', function (data) {
            layer.tips('【实体】是否生成SerialVersionUID', data.othis)
        });
        form.on('switch(switchBaseResultMap)', function (data) {
            layer.tips('【xml】文件是否生成BaseResultMap', data.othis)
        });
        form.on('switch(switchSwagger2)', function (data) {
            layer.tips('是否为【实体】和【控制器】生成文档', data.othis)
        });
        //监听提交
        form.on('submit(save-setting)', function (data) {
            var field = data.field;
            for (x in field) {
                if (field[x] === '' || field[x] === undefined) {
                    delete field[x];
                }
            }
            setter.putSetting(field);
            layer.msg("保存成功", {icon: 1});
            return false;
        });

        //表单赋值
        var data = setter.getSetting();
        if (data !== null || data !== '' || data !== undefined) {
            form.val('settingData', data);
        }


    });
</script>

</body>
</html>